
//
//  NowSearchCell.m
//  BusinessMarket
//
//  Created by Michael Li on 2018/12/21.
//  Copyright © 2018年 Michael Li. All rights reserved.
//

#import "NowSearchCell.h"
#import "SpecialRecommendationModel.h"
#import "ShopSubModel.h"
#import "ServiceModel.h"
#import "HomeModel.h"
@interface NowSearchCell()
@property (weak, nonatomic) IBOutlet UILabel *titleL;
@property (weak, nonatomic) IBOutlet UILabel *markL;

@end
static NSString *identifier = @"NowSearchCell";
@implementation NowSearchCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
+(instancetype)cellNibWithTableView:(UITableView *)tableView
{
    NowSearchCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (!cell) {
        [tableView registerNib:[UINib nibWithNibName:@"NowSearchCell" bundle:nil] forCellReuseIdentifier:identifier];
        cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}
- (void)setTitle:(NSString *)title
{
    _title = title;
}
- (void)setSpecialModel:(SpecialRecommendationModel *)specialModel
{
    _specialModel= specialModel;
    self.markL.text = @"专题合集";
    self.markL.layer.cornerRadius = 3;
    self.markL.textColor = kWhite;
    self.markL.backgroundColor = kOrangeBg;
    NSRange range = [specialModel.title rangeOfString:self.title];
    NSMutableAttributedString *attribute = [[NSMutableAttributedString alloc] initWithString:specialModel.title];
    [attribute addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1] range:range];
    [self.titleL setAttributedText:attribute];
}
- (void)setSubShopModel:(ShopSubModel *)subShopModel
{
    _subShopModel = subShopModel;
    XLog(@"subShopModel.title:%@",subShopModel.title);
    self.markL.text = @"店铺";
    self.markL.layer.masksToBounds = YES;
    self.markL.layer.cornerRadius = 3;
    self.markL.layer.borderWidth  = 1;
    self.markL.backgroundColor = [UIColor clearColor];
    self.markL.layer.borderColor  = kOrangeBg.CGColor;
    self.markL.textColor = kOrangeBg;
    NSRange range = [subShopModel.title rangeOfString:self.title];
    NSMutableAttributedString *attribute = [[NSMutableAttributedString alloc] initWithString:subShopModel.title];
    [attribute addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1] range:range];
    [self.titleL setAttributedText:attribute];
}
- (void)setServiceModel:(ServiceModel *)serviceModel
{
    _serviceModel = serviceModel;
    self.markL.text = @"服务";
    self.markL.layer.masksToBounds = YES;
    self.markL.layer.cornerRadius = 3;
    self.markL.layer.borderWidth  = 1;
    self.markL.backgroundColor = [UIColor clearColor];
    self.markL.layer.borderColor  = kOrangeBg.CGColor;
    self.markL.textColor = kOrangeBg;
//    self.markL.backgroundColor = kOrangeBg
    XLog(@"serviceModel.represent:%@",serviceModel.represent);
//    self.titleL.text = serviceModel.resource;
    NSRange range = [serviceModel.resource rangeOfString:self.title];
    NSMutableAttributedString *attribute = [[NSMutableAttributedString alloc] initWithString:serviceModel.resource];
    [attribute addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1] range:range];
    [self.titleL setAttributedText:attribute];
}
- (void)setModel:(HomeModel *)model
{
    _model = model;
    XLog(@"model.title:%@",model.title);
    self.markL.text = @"需求";
    self.markL.layer.borderColor  = kOrangeBg.CGColor;
    self.markL.textColor = kOrangeBg;
    self.markL.layer.masksToBounds = YES;
    self.markL.backgroundColor = [UIColor clearColor];
    self.markL.layer.cornerRadius = 3;
    self.markL.layer.borderWidth  = 1;
//    self.titleL.text = model.title;
    NSRange range = [model.title rangeOfString:self.title];
    NSMutableAttributedString *attribute = [[NSMutableAttributedString alloc] initWithString:model.title];
    [attribute addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1] range:range];
    [self.titleL setAttributedText:attribute];
}

@end
